﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Gebra.Test
{
    [TestClass]
    public class SubtractTest
    {
        [TestMethod]
        public void ConstructWithNumbers()
        {
            var subtract = new Subtract((Number) 56.75, (Number) 0.75);

            var result = subtract.Evaluate() as Number;

            Assert.IsNotNull(result);
            Assert.AreEqual(56, (double)result);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructWithNullLeft()
        {
            new Subtract(a_left: null, a_right: (Number)42);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructWithNullRight()
        {
            new Subtract((Number)23, a_right: null);
        }

        [TestMethod]
        public void EvaluateThreeNumberSubtraction()
        {
            // 100 - 30 - 4 = 66
            var subtract = new Number(100).Subtract(30).Subtract(4);

            var result = subtract.Evaluate() as Number;

            Assert.IsNotNull(result);
            Assert.AreEqual(66, (double) result);
        }

        [TestMethod]
        public void EvaluateAdditionWithSubtraction()
        {
            // 100 - 30 + 4 == 74
            var operand = new Number(100).Subtract(30).Add(4);

            var result = operand.Evaluate() as Number;

            Assert.IsNotNull(result);
            Assert.AreEqual(74, (double) result);
        }
    }
}
